home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / text / edit / tecoc-146.lha / clenup.c < prev    next >
C/C++ Source or Header  |  1991-07-05  |  2KB  |  63 lines

  1. /*****************************************************************************
  2.  
  3.     ClenUp()
  4.  
  5.     This function "cleans up" in preparation for terminating TECO-C. All
  6. open files are closed and memory is freed.
  7.  
  8. *****************************************************************************/
  9.  
  10. #include "zport.h"        /* define portability identifiers */
  11. #include "tecoc.h"        /* define general identifiers */
  12. #include "defext.h"        /* define external global variables */
  13.  
  14. VVOID ClenUp (VVOID)        /* cleanup for TECO-C abort */
  15. {
  16.     QRptr    QRp;
  17.     int    i;
  18.  
  19.     ZIClos(PINPFL);        /* Close the primary and secondary... */
  20.     ZIClos(SINPFL);        /* ...input streams,  if they're open */
  21.  
  22.     ZOClDe(POUTFL);        /* Close the primary and secondary... */
  23.     ZOClDe(SOUTFL);        /* ...output streams,  if they're open */
  24.  
  25. /*
  26.  * free dynamically allocated buffers
  27.  */
  28.  
  29.     if (CBfBeg) ZFree((voidptr)CBfBeg);    /* the command buffer */
  30.     if (DBfBeg) ZFree((voidptr)DBfBeg);    /* the digit buffer */
  31.     if (EBfBeg) ZFree((voidptr)EBfBeg);    /* the edit buffer */
  32.     if (FBfBeg) ZFree((voidptr)FBfBeg);    /* the filename buffer */
  33.     if (SBfBeg) ZFree((voidptr)SBfBeg);    /* the search string buffer */
  34.  
  35. /*
  36.  * free the global [0-35] and main-level local [36-71] Q-registers,
  37.  * and then the Q-register stack.
  38.  */
  39.  
  40.     for (QRp = QRgstr, i = 0; i < 72; ++i, ++QRp) {
  41.         if (QRp->Start != NULL) {
  42.             ZFree((voidptr)QRp->Start);
  43.         }
  44.     }
  45.     for (QRp = QStack, i = 0; i < QRS_SIZE; ++i, ++QRp) {
  46.         if (QRp->Start != NULL) {
  47.             ZFree((voidptr)QRp->Start);
  48.         }
  49.     }
  50.     ZClnUp();            /* do system-dependent cleanup */
  51.  
  52. #if DEBUGGING
  53. {
  54. /*
  55.  * at this point, there shouldn't be any block malloc'ed by TECO-C.
  56.  * except if we're here because we EX'ed out of a macro, and we can't
  57.  * get to the ZBf buffer allocated in ExeEI,  so the ZBf buffer is
  58.  * left hanging.
  59.  */
  60. }
  61. #endif
  62. }
  63.